package com.mjl.shops.activity;


import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

import com.mjl.shops.R;
import com.mjl.shops.base.BaseActivity;
import com.mjl.shops.view.dialog.GoodsDetailsBuyDialog;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class GoodsDetailsActivity extends BaseActivity {

    private GoodsDetailsBuyDialog goodsDetailsBuyDialog;

    @BindView(R.id.buy_tv)
    TextView mBuy;

    @Override
    protected void setContentViewBefore() {
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    }

    @Override
    protected int getViews() {
        return R.layout.activity_goods_details;
    }

    @Override
    protected void setViews() {
        ButterKnife.bind(this);
    }

    @Override
    protected void setDate() {

    }

    @Override
    protected String getStateColor() {
        return "";
    }

    @Override
    protected int getStetaBackgroundStyle() {
        return 2;
    }

    @OnClick({R.id.buy_tv,R.id.icon_back})
    public void OnClick(View view) {
        switch (view.getId()) {
            case R.id.buy_tv:
                if (goodsDetailsBuyDialog == null){
                    goodsDetailsBuyDialog = new GoodsDetailsBuyDialog(GoodsDetailsActivity.this);
                    goodsDetailsBuyDialog.setBuyDialogListener(new GoodsDetailsBuyDialog.BuyDialogListener() {
                        @Override
                        public void buy() {
                            SubmitOrderActivity.StartIntent(GoodsDetailsActivity.this);
                        }

                        @Override
                        public void shutDown() {

                        }
                    });
                }
                goodsDetailsBuyDialog.Shows();
                break;
            case R.id.icon_back:
                finish();
                break;
        }
    }

    @Override
    protected void onStop() {
        super.onStop();
        if (goodsDetailsBuyDialog!=null&&goodsDetailsBuyDialog.getIsShow()){
            goodsDetailsBuyDialog.ShutDown();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (goodsDetailsBuyDialog!=null){
            goodsDetailsBuyDialog.release();
        }
    }

    public static void StartIntent(Context contexts) {
        Intent intent = new Intent(contexts, GoodsDetailsActivity.class);
        contexts.startActivity(intent);
    }
}
